﻿namespace Basic.EventBus
{
    public interface IBusBrokerConfig
    {
        string BrokerType { get; }
        string Host { get; }
        int Port { get; }
        string User { get; }
        string Passwd { get; }
        string SerializerName { get; }
        bool AutoAck { get; }
        ushort Qos { get; }
    }

    public class RabbitMQBusBrokerConfig : IBusBrokerConfig
    {
        /// <summary>
        /// 默认虚拟主机
        /// </summary>
        public const string DefaultVirtualHost = "/";
        /// <summary>
        /// 单帧大小限制64M
        /// </summary>
        public const int RequestedFrameMax = 1024 * 1024 * 64;

        public string BrokerType { get; set; }

        public string Host { get; set; }

        public int Port { get; set; }

        public string User { get; set; }

        public string Passwd { get; set; }

        public string VirtualHost { get; set; }

        public bool PushModel { get; set; } = true;

        /// <summary>
        /// 心跳超时(秒:s)
        /// </summary>
        public int HeartbeatTimeout { get; set; } = 600;

        public ushort PoolSize { get; set; }

        public string SerializerName { get; set; } = "json";

        public bool AutoAck { get; set; } = true;

        public ushort Qos { get; set; }
    }

    public class KafkaBusBrokerConfig : IBusBrokerConfig
    {
        public string Servers { get; set; }

        public string BrokerType { get; set; }

        public string Host { get; set; }

        public int Port { get; set; }

        public string User { get; set; }

        public string Passwd { get; set; }

        public string SerializerName { get; set; } = "json";
        public bool AutoAck { get; set; } = true;

        public ushort Qos { get; set; }

    }
}